package mz.co.research.client.view.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class DataView implements Serializable {

	/**
	 * Serial Version UID
	 */
	private static final long serialVersionUID = 4835209340552742565L;

	private Map<String, Object> vMap = new HashMap<String, Object>();

	public void set(String key, Object value) {
		this.vMap.put(key, value);
	}

	public Object get(String key) {
		return this.vMap.get(key);
	}

	@SuppressWarnings("unchecked")
	public void add(String key, Object value) {
		List<Object> l = (List<Object>) this.get(key);

		if (l == null) {
			this.set(key, l = new ArrayList<Object>());
		}

		l.add(value);
	}

	@SuppressWarnings("rawtypes")
	public List getList(String key) {
		List l = (List) this.get(key);

		if (l == null) {
			this.set(key, l = new ArrayList<Object>());
		}

		return l;
	}
}
